<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta name="generator" content="HTML Tidy for Linux/x86 (vers 1st November 2003), see www.w3.org"/>
    <title>JavaScript: Closure Test</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="copyright" content="Copyright &#169; 2005-2010 W3C (MIT, ERCIM, Keio)"/>
    <meta name="duration" content="5"/>
    <meta name="font-size-adjustment" content="-2"/>

    <link rel="stylesheet" href="styles/slidy.css" type="text/css"/>
    <link rel="stylesheet" href="styles/w3c-blue.css" type="text/css"/>
	<script type="text/javascript" src="scripts/slidy.js" charset="utf-8">//</script>

    <link type="text/css" rel="stylesheet" href="styles/shCoreDefault.css"/>
    <script type="text/javascript" src="scripts/shCore.js"></script>
    <script type="text/javascript" src="scripts/shBrushJScript.js"></script>

    <link type="text/css" rel="stylesheet" href="styles/presentation.css"/>
    <script type="text/javascript" src="scripts/presentation.js"></script>
</head>


<body>
<div class="background">
    <img alt="" id="head-icon" src="graphics/icon-blue.png"/>
</div>

<div class="background slanty">
</div>

<div class="slide cover title">
    <img class="hidden" src="graphics/bullet.png" alt=""/>
    <img class="hidden" src="graphics/fold.gif" alt=""/>
    <img class="hidden" src="graphics/unfold.gif" alt=""/>
    <img class="hidden" src="graphics/fold-dim.gif" alt=""/>
    <img class="hidden" src="graphics/nofold-dim.gif" alt=""/>
    <img class="hidden" src="graphics/unfold-dim.gif" alt=""/>
    <img class="hidden" src="graphics/bullet-fold.gif" alt=""/>
    <img class="hidden" src="graphics/bullet-unfold.gif" alt=""/>
    <img class="hidden" src="graphics/bullet-fold-dim.gif" alt=""/>
    <img class="hidden" src="graphics/bullet-nofold-dim.gif" alt=""/>
    <img class="hidden" src="graphics/bullet-unfold-dim.gif" alt=""/>

    <h1>JavaScript: Closure Test</h1>

    <p>Alex Kolonitsky</p>
</div>

<div class="slide">
    <h1>01</h1>

    <pre class="brush: js">
        (function (x) {
            delete x;
            return x;
        })(1);
    </pre>

    <ul class="incremental">
        <li>1</li>
        <li>null</li>
        <li>undefined</li>
        <li>Error</li>
    </ul>
</div>

<div class="slide">
    <h1>02</h1>

    <pre class="brush: js">
        var foo = {
            bar: function () {return this.baz;},
            baz: 1
        };
        typeof (f = foo.bar)();
    </pre>
    
    <ul class="incremental">
        <li>"undefined"</li>
        <li>"object"</li>
        <li>"number"</li>
        <li>"function"</li>
        <li>Error</li>
    </ul>
</div>

<div class="slide">
    <h1>03</h1>

    <pre class="brush: js">
        var x = 1;
        if (function f() {}) {
            x += typeof f;
        }
        x;
    </pre>

    <ul class="incremental">
        <li>1</li>
        <li>"1number"</li>
        <li>"1undefined"</li>
        <li>NaN</li>
    </ul>
</div>

<div class="slide">
    <h1>04</h1>

    <pre class="brush: js">
        var x = [typeof x, typeof y][1];
        typeof typeof x;
    </pre>

    <ul class="incremental">
        <li>"number"</li>
        <li>"string"</li>
        <li>"undefined"</li>
        <li>"object"</li>
    </ul>
</div>

<div class="slide">
    <h1>05</h1>

    <pre class="brush: js">
        (function (foo) {
            return typeof foo.bar;
        }) ({ foo: { bar: 1}});
    </pre>

    <ul class="incremental">
        <li>"undefined"</li>
        <li>"object"</li>
        <li>"number"</li>
        <li>Error</li>
    </ul>
</div>

<div class="slide">
    <h1>06</h1>

    <pre class="brush: js">
        (function f () {
            function f () {return 1;}
            return f();
            function f () {return 2;}
        }) ();
    </pre>

    <ul class="incremental">
        <li>1</li>
        <li>2</li>
        <li>Error (e.g. "Too much recursion")</li>
        <li>undefined</li>
    </ul>
</div>

<div class="slide">
    <h1>07</h1>

    <pre class="brush: js">
        (function () {
            var a = sum(2, 2);

            function sum(x, y) {return x + y}
            console.log(a);
        })()
    </pre>
</div>

<div class="slide">
    <h1>08</h1>

    <pre class="brush: js">
        (function () {
            var a = sum(2, 2);

            var sum = function (x, y) {return x + y}
            console.log(a);
        })()
    </pre>
</div>

</body>

</html>
